public class LC345 {
    public String reverseVowels(String s){
        int i=0;
        int j=s.length()-1;
        char[] str=s.toCharArray();
        while(i<j){
            while (str[i]!='a' && str[i]!='o' && str[i]!='e' && str[i]!='i' && str[i]!='u' && i<j && str[i]!='A' && str[i]!='O' && str[i]!='E' && str[i]!='I' && str[i]!='U'){
                i++;
            }
            while(str[j]!='a' && str[j]!='o' && str[j]!='e' && str[j]!='i' && str[j]!='u' && i<j && str[j]!='A' && str[j]!='O' && str[j]!='E' && str[j]!='I' && str[j]!='U'){
                j--;
            }
            if (i!=j){
                char tmp=str[i];
                str[i]=str[j];
                str[j]=tmp;
                i++;
                j--;
            }
        }
        return new String(str);
    }

}
